import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'


Vue.use(VueRouter)

// //解决编程式路由往同一地址跳转时会报错的情况
// const originalPush = VueRouter.prototype.push;
// const originalReplace = VueRouter.prototype.replace;
// //push
// VueRouter.prototype.push = function push(location, onResolve, onReject) {
//   if (onResolve || onReject)
//     return originalPush.call(this, location, onResolve, onReject);
//   return originalPush.call(this, location).catch(err => err);
// };
// //replace
// VueRouter.prototype.replace = function push(location, onResolve, onReject) {
//   if (onResolve || onReject)
//     return originalReplace.call(this, location, onResolve, onReject);
//   return originalReplace.call(this, location).catch(err => err);
// };


const routes = [
{
  path:'/',
  name:'Home',
  component:Home
},
{
  path:'/more/:name/:tab',
  name:'More',
  props:true,
  component:()=>import ('../views/More')
},
// 此上下两路径指向同一组件，参数与路径不同
{
  path:'/evenMore/:name/:cateid',
  name:'evenMore',
  props:true,
  component:()=>import ('../views/More')
},
{
  path:'/own',
  name:'Own',
  props:true,
  component:()=>import ('../views/Own')
},
{
  path:'/ownMv/:id',
  name:'OwnMv',
  props:true,
  component:()=>import ('../views/OwnMv')
},
{
  path:'/behindthescenes',
  name:'BehindTheScenes',
  component:()=>import ('../views/BehindTheScenes')
},
{
  path:'/special/:id',
  name:'Special',
  props:true,
  component:()=>import ('../views/Special')
},
{
  path:'/ineo',
  name:'Ineo',
  props:true,
  component:()=>import ('../views/Ineo')
},
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
